package com.dys.test04;

/**
 * @className: com.dys.test04.BuyTicketThread
 * @description: com.dys.test04
 * @author: pine cone
 * @version: v1.0.0
 * @createTime: 2024/08/17 下午10:05
 */
public class BuyTicketThread implements Runnable {
    int ticketNum = 10;

    // 每个窗口都有一个线程对象，每个窗口有1000个人在抢票
    @Override
    public void run() {
        for (int i = 1; i <= 1000; i++) {
            if (ticketNum > 0) {
                System.out.println("我在" + Thread.currentThread().getName() + "：购买了从【深圳-->贵阳】的第" + ticketNum-- + "张火车票");
            }
        }
    }
}
